<?php
namespace app\common\model\project_model;

use app\common\helper\Obj2Array;
use app\common\model\Base;
use think\Model;

class SystemMusicCategoryModel extends Model {

    const STATUS_OK = 1;
    const STATUS_LOCK = 0;

    protected $table = 'ph_system_music_category';

    public static function statusList() {
        return [
            self::STATUS_LOCK => '锁定',
            self::STATUS_OK => '启用'
        ];
    }

    /**
     * 分类list
     *
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public static function CategoryList() {
        $categoryM = new self();
        $categoryD = $categoryM->field(['id', 'title'])->where(['status' => self::STATUS_OK])->order(['sort' => 'ASC'])->select();
        if (!$categoryD) {
            return [];
        }

        return Obj2Array::resObject2Array($categoryD);
    }

}